//
//  DiscoverViewController.m
//  123
//
//  Created by Wang on 14/11/19.
//  Copyright (c) 2014年 Wang. All rights reserved.
//

#import "DiscoverViewController.h"
#import "DiscoverCell.h"
#import "HowToViewController.h"
#import "TTViewController.h"
#include "ThemeViewController.h"

@interface DiscoverViewController ()<UITableViewDataSource, UITableViewDelegate>

@end

@implementation DiscoverViewController

- (void)dealloc
{
    [super dealloc];
}

- (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        
    }
    return self;
}

- (void)viewDidLoad {
    
    [super viewDidLoad];
    [self.navigationItem setTitle:@"发现"];
    [self.navigationController.navigationBar setTranslucent:NO];
    [self.view setBackgroundColor:[UIColor whiteColor]];
    [self creatTabView];
}

#pragma mark - 创建TableView 并注册cell
- (void)creatTabView
{
    UITableView *tab = [[[UITableView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height - 49) style:UITableViewStylePlain] autorelease];
    tab.delegate = self;
    tab.dataSource = self;
    [self.view addSubview:tab];
    [tab registerClass:[DiscoverCell class] forCellReuseIdentifier:@"cell"];
}

#pragma mark - 每个section 有多少个row
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 3;
}

#pragma mark - row的高度
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 50;
}

#pragma mark - 遵循协议内容
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    DiscoverCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
    
    
    NSMutableArray *labelArr = [NSMutableArray arrayWithObjects:@"主题", @"T台", @"怎么搭", nil];
    [cell.rightLabel setText:[labelArr objectAtIndex:indexPath.row]];
    
    
    NSMutableArray *imageArr = [NSMutableArray arrayWithObjects:@"主题.png", @"T台.png", @"搭配.png", nil];
    [cell.leftImageView setImage:[UIImage imageNamed:[imageArr objectAtIndex:indexPath.row]]];
    
    return cell;
}

#pragma mark - cell 点击事件
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    
    if (indexPath.row == 0) {
        ThemeViewController *theme = [[[ThemeViewController alloc] init] autorelease];
        [self.navigationController pushViewController:theme animated:YES];
    }
    if (indexPath.row == 1) {
        TTViewController *TTai = [[[TTViewController alloc] init] autorelease];
        [self.navigationController pushViewController:TTai animated:YES];
    }
    if (indexPath.row == 2) {
        HowToViewController *howTo = [[[HowToViewController alloc] init] autorelease];
        [self.navigationController pushViewController:howTo animated:YES];
    }
}

@end
